package com.sun.rabbit.workQueues;


import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import com.sun.rabbit.utils.RabbitMqUtils;



/**工作队列一（消费者）
 * @author shkstart
 * @create 2021-10-10 18:57
 */
public class Work01 {
    private static final String QUEUE_NAME="hello";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();

        DeliverCallback deliverCallback = (consumerTag,delivery)->{
            String message = new String(delivery.getBody(),"utf-8");
            System.out.println("接收到的消息:"+message);
        };
        CancelCallback cancelCallback=(consumerTag)->{
            System.out.println(consumerTag+" 消费者取消消费接口回调逻辑");
        };

        System.out.println("c2消费者等待消费。。。");
        channel.basicConsume(QUEUE_NAME,true,deliverCallback,cancelCallback);
    }
}
